package controlLayer;
import modelLayer.*;
import java.util.*;

public class RentCtr {
    
    private MachineContainer machineContainer;
    private RentContainer rentCont;
    private CustomerCtr custCtr;
    private EmployeeCtr empCtr;
    private MachineCtr mcnCtr;
    private Customer cust;
    private Employee emp;
    private Machine mcn;
    private double subtotal;
    private double total;
    
    public RentCtr() {
        machineContainer = MachineContainer.getInstance();
        custCtr = new CustomerCtr();
        empCtr = new EmployeeCtr();
        mcnCtr = new MachineCtr();
        rentCont = RentContainer.getInstance();
        
    }
    
    public void createRent(int ccpr, int ecpr, int barcode, String period, String rentDate, double total) {
        cust = custCtr.findCustomer(ccpr);
        emp = empCtr.findEmployee(ecpr);
        mcn = mcnCtr.findMachine(barcode);
        Rent rent = new Rent(period, rentDate, cust, emp, mcn, total);
        rentCont.addRent(rent);
        System.out.println("Rent " + rent.getRentId() + " has been succesfully created");
    }
    
    public Rent findRent(int rentId) {
        Rent rent = rentCont.findRent(rentId);
        return rent;
    }
    
    public int inputBarcode() {
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Enter the barcode of the machine (numeric value) : ");
        int serialNumber = keyboard.nextInt();
        return serialNumber;
    }
    
    public int inputQuantity() {
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Enter the quantity : ");
        int quantity = keyboard.nextInt();
        return quantity;
    }
    
    private String inputRentDate() {
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Enter the rent starting date (dd/mm/yyyy) : ");
        String date = keyboard.nextLine();
        return date;
    }
    
    private String inputPeriod() {
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Enter the rent period (in days) : ");
        String date = keyboard.nextLine();
        return date;
    }
    
}
